package com.jeomo.mem.starter.mapper;

import com.jeomo.base.starter.mapper.IBaseMapper;
import com.jeomo.mem.starter.entity.MemberPointsRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 会员积分规则
 * @author:Jackpot
 * @create 2020-09-09 14:51
 * @description:
 */
@Mapper
public interface MemberPointsRuleMapper extends IBaseMapper<MemberPointsRule> {

    /**
     * 获取积分规则
     * @param level 会员等级
     * @param bsCode    业务编码 (如商品编码)
     * @return
     */
    @Select(" select m.rule from " +
            " member_points_rule as m join member_points_rule_list as d on m.id=d.rule_id  " +
            " where m.start_flag =1 and LOCATE(#{level},m.use_level) >0 and d.bs_code=#{bsCode} ")
    String getMemberPointsRule(String level,String bsCode);

    @Update("update member_points_rule set start_flag=#{status} where id=#{ruleId}")
    int updateRuleStatus(Long ruleId,int status);


}
